<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title></title>
    <link rel="stylesheet" href="../assets/common/libs/layui/css/layui.css" media="all">
</head>
<body>

<form class="layui-form layui-form-pane" action="" method="post">
    <!--属性有ID，日程名称，组织，共享ID（用于生成共享链接），创建的日 期，创建用户ID，开始日期，结束日期，周数量-->
    <div class="layui-inline">
        <label class="layui-form-label">日程表名称</label>
        <div class="layui-input-inline">
            <input type="text" value="${sformIdInt}" id="sformId" hidden>
            <input type="text" name="sframe_name" id="" value="${sformName}" lay-verify="sframe_name" autocomplete="off" disabled class="layui-input">
        </div>
    </div>
<!--    <div class="layui-inline">
        <label class="layui-form-label">组织</label>
        <div class="layui-input-inline">
            <input type="text" name="organization" lay-verify="organization" id="organization" value="" autocomplete="off" class="layui-input">
        </div>
    </div>-->
<!--    <div class="layui-inline">
        <label class="layui-form-label">开始日期</label>
        <div class="layui-input-inline">
            <input type="text" name="start_time" id="start_time" lay-verify="date" placeholder="年-月-日" value="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-input-inline">
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">保存</button>
    </div>-->

</form>
<table class="layui-hide" id="test" lay-filter="test"></table>

<script src="../assets/common/libs/layui/layui.all.js"></script>

<!-- js部分 -->
@/* 加入contextPath属性和session超时的配置 */
<script type="text/javascript">
    var Feng = {
        ctxPath: "${ctxPath}",
        version: '${constants.getReleaseVersion()}'
    };
</script>

<script>
    layui.use(['table','laydate','jquery','form','layer','layedit'],function(){
        var table = layui.table;
        var $ =layui.jquery;
        var form = layui.form;
        var layer = layui.layer;
        var layedit = layui.layedit;
        var laydate = layui.laydate;

        /**
         * 系统管理--用户管理
         */
        var MgrUser = {
            tableId: "userTable",    //表格id
            condition: {
                name: "",
                deptId: "",
                timeLimit: ""
            }
        };


        laydate.render({
            elem: '#start_time'
        });


        $(function () {
            var sformId=$("#sformId").val();
            var items={};
            var item=[];
            $.post({
                url:"/myScheduleForm/checkScheduleForm2?sformId="+sformId,
                success:function (data) {
                    alert(data.scheduleForm.sformName);
                    for(var i=0;i<data.scheduleForm.scheduleFrame.scheduleFrameItems.length;i++){
                       alert( JSON.stringify( data.scheduleForm.scheduleFrame.scheduleFrameItems ));
                        alert( JSON.stringify( data.scheduleFormItems ));

                    }




                    table.render({
                        elem: '#test'
                        ,even: true
                        ,title: data.scheduleForm.sformName
                        ,toolbar: true
                        ,defaultToolbar: ['exports']
                        ,cellMinWidth: 120
                        ,cols: [[
                            {field:'timeid', title: '时间' ,align: 'center',rowspan: 2}
                            ,{field:'sunday', title: '周日' ,align: 'center',event: 'setSunday'}
                            ,{field:'monday', title: '周一',align: 'center',event: 'setMonday'}
                            ,{field:'tuesday', title: '周二',align: 'center',event: 'setTuesday'}
                            ,{field:'wednesday', title: '周三',align: 'center',event: 'setWednesday'}
                            ,{field:'thursday', title: '周四',align: 'center',event: 'setThursday'}
                            ,{field:'friday', title: '周五', align: 'center',event: 'setFriday'}
                            ,{field:'saturday', title: '周六',  align: 'center',event: 'setSaturday'}
                        ]]

                        ,data: [
                            {
                                "timeid": "14:00:00--15:00:00"
                                ,"sunday": "休息"
                                ,"monday": "计算机原理"
                                ,"tuesday": "11"
                                ,"wednesday": "体育"
                                ,"thursday": "11"
                                ,"friday": "11"
                                ,"saturday":"四六级考试"
                            },
                            {
                                "timeid": "2"
                                ,"sunday": ""
                                ,"monday": ""
                                ,"tuesday": ""
                                ,"wednesday": ""
                                ,"thursday": ""
                                ,"friday": ""
                                ,"saturday":""
                            },
                            {
                                "timeid": "3"
                                ,"sunday": ""
                                ,"monday": ""
                                ,"tuesday": ""
                                ,"wednesday": ""
                                ,"thursday": ""
                                ,"friday": ""
                                ,"saturday":""
                            },
                            {
                                "timeid": "4"
                                ,"sunday": ""
                                ,"monday": ""
                                ,"tuesday": ""
                                ,"wednesday": ""
                                ,"thursday": ""
                                ,"friday": ""
                                ,"saturday":""
                            },
                            {
                                "timeid": "5"
                                ,"sunday": ""
                                ,"monday": ""
                                ,"tuesday": ""
                                ,"wednesday": ""
                                ,"thursday": ""
                                ,"friday": ""
                                ,"saturday":""
                            },
                            {
                                "timeid": "6"
                                ,"sunday": ""
                                ,"monday": ""
                                ,"tuesday": ""
                                ,"wednesday": ""
                                ,"thursday": ""
                                ,"friday": ""
                                ,"saturday":""
                            },
                            {
                                "timeid": "7"
                                ,"sunday": ""
                                ,"monday": ""
                                ,"tuesday": ""
                                ,"wednesday": ""
                                ,"thursday": ""
                                ,"friday": ""
                                ,"saturday":""
                            },
                            {
                                "timeid": "8"
                                ,"sunday": ""
                                ,"monday": ""
                                ,"tuesday": ""
                                ,"wednesday": ""
                                ,"thursday": ""
                                ,"friday": ""
                                ,"saturday":""
                            },
                            {
                                "timeid": "9"
                                ,"sunday": ""
                                ,"monday": ""
                                ,"tuesday": ""
                                ,"march": ""
                                ,"thursday": ""
                                ,"friday": ""
                                ,"saturday":""
                            },
                            {
                                "timeid": "10"
                                ,"sunday": ""
                                ,"monday": ""
                                ,"tuesday": ""
                                ,"wednesday": ""
                                ,"thursday": ""
                                ,"friday": ""
                                ,"saturday":""
                            }]

                        ,response: {
                            statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
                        }
                        ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
                            return {
                                "code": res.status, //解析接口状态
                                "msg": res.message, //解析提示文本
                                "count": res.total, //解析数据长度
                                "data": res.rows.item //解析数据列表
                            };
                        }

                    });








                }
            });
        });


        table.on('tool(test)', function(obj){
            var data = obj.data;
            if(obj.event === 'setSunday'){
                layer.open({
                    type:2,
                    area: ['800px', '400px'],
                    title: '添加周日日程项',
                    content: Feng.ctxPath + '/myScheduleFormItem/createSformItem?sformId=3&serial=1&sformItemDate=2019-12-11 00:00:00&startTime=2019-12-11 00:00:00&stopTime=2019-12-11 00:00:00',
                    tableId: MgrUser.tableId
                }, function(value, index){
                    layer.close(index);
                    //这里一般是发送修改的Ajax请求
                    //同步更新表格和缓存对应的值
                    obj.update({
                        sunday: value
                    });
                });
            };
            if(obj.event === 'setMonday'){'修改周一第'+ data.timeid +'节课的日程安排'
                layer.open({
                    type:2,
                    area: ['800px', '400px'],
                    title: '添加周二第'+ data.timeid +'节课的日程安排',
                    content: Feng.ctxPath + '/myScheduleFormItem/createSformItem?sformId=1&serial=1&sformItemDate=2019-12-11 00:00:00&startTime=2019-12-11 00:00:00&stopTime=2019-12-11 00:00:00',
                    tableId: MgrUser.tableId
                }, function(value, index){
                    layer.close(index);
                    //这里一般是发送修改的Ajax请求
                    //同步更新表格和缓存对应的值
                    obj.update({
                        monday: value
                    });
                });
            };
            if(obj.event === 'setTuesday'){

                layer.open({
                    type:2,
                    area: ['800px', '400px'],
                    title: '添加周二日程项',
                    content: Feng.ctxPath + '/myScheduleFormItem/createSformItem?sformId=1&serial=1&sformItemDate=2019-12-11 00:00:00&startTime=2019-12-11 00:00:00&stopTime=2019-12-11 00:00:00',
                    tableId: MgrUser.tableId
                }, function(value, index){
                    layer.close(index);
                    //这里一般是发送修改的Ajax请求
                    //同步更新表格和缓存对应的值
                    obj.update({
                        tuesday: value
                    });
                });
            };
            if(obj.event === 'setWednesday'){
                layer.open({
                    type:2,
                    area: ['800px', '400px'],
                    title: '添加周三日程项',
                    content: Feng.ctxPath + '/myScheduleFormItem/createSformItem?sformId=1&serial=1&sformItemDate=2019-12-11 00:00:00&startTime=2019-12-11 00:00:00&stopTime=2019-12-11 00:00:00',
                    tableId: MgrUser.tableId
                }, function(value, index){
                    layer.close(index);
                    //这里一般是发送修改的Ajax请求
                    //同步更新表格和缓存对应的值
                    obj.update({
                        wednesday: value
                    });
                });
            };
            if(obj.event === 'setThursday'){
                layer.open({
                    type:2,
                    area: ['800px', '400px'],
                    title: '添加周四日程项',
                    content: Feng.ctxPath + '/myScheduleFormItem/createSformItem?sformId=1&serial=1&sformItemDate=2019-12-11 00:00:00&startTime=2019-12-11 00:00:00&stopTime=2019-12-11 00:00:00',
                    tableId: MgrUser.tableId
                }, function(value, index){
                    layer.close(index);
                    //这里一般是发送修改的Ajax请求
                    //同步更新表格和缓存对应的值
                    obj.update({
                        thursday: value
                    });
                });
            };
            if(obj.event === 'setFriday'){
                layer.open({
                    type:2,
                    area: ['800px', '400px'],
                    title: '添加周五日程项',
                    content: Feng.ctxPath + '/myScheduleFormItem/createSformItem?sformId=1&serial=1&sformItemDate=2019-12-11 00:00:00&startTime=2019-12-11 00:00:00&stopTime=2019-12-11 00:00:00',
                    tableId: MgrUser.tableId
                }, function(value, index){
                    layer.close(index);
                    //这里一般是发送修改的Ajax请求
                    //同步更新表格和缓存对应的值
                    obj.update({
                        friday: value
                    });
                });
            };
            if(obj.event === 'setSaturday'){
                layer.open({
                    type:2,
                    area: ['800px', '400px'],
                    title: '添加周六日程项',
                    content: Feng.ctxPath + '/myScheduleFormItem/createSformItem?sformId=1&serial=1&sformItemDate=2019-12-11 00:00:00&startTime=2019-12-11 00:00:00&stopTime=2019-12-11 00:00:00',
                    tableId: MgrUser.tableId
                }, function(value, index){
                    layer.close(index);
                    alert("sdHRAEN");
                    //这里一般是发送修改的Ajax请求
                    $.post({
                        url:"/myScheduleFrame/copySframe?sformId=1&sframeItemSerail=1&sformItemDate=2019-12-25",

                        success:function (data) {
                            alert(JSON.stringify(data))


                        }
                    });


                    //同步更新表格和缓存对应的值
                    obj.update({
                        saturday: value
                    });
                });
            };
        });



        <!--  form.verify({-->
        <!--    sframe_name: function(value){-->
        <!--      if(value.length < 0){-->
        <!--        return '名称不能为空';-->
        <!--      }-->
        <!--    }-->
        <!--  });-->
        <!--  form.on('submit(demo1)', function(data){-->
        <!--    layer.alert(JSON.stringify(data.field), {-->
        <!--      title: '最终的提交信息'-->
        <!--    })-->
        <!--    return false;-->
        <!--  });-->


    });
</script>

</body>
</html>